
<section>
	<div class="page_title">
		<h2 class="fl">添加权限</h2>
        <a class="fr top_rt_btn iconfont iconfont-chexiao" href="{:U('admin/Auth/authList')}">权限列表</a>
	</div>

	<ul class="ulColumn2">
		{present name="no_data"}
			<li>
				<span class="item_name" style="width:120px;">权限路径：</span>
				<span class="no-data" style="width:120px;">{$no_data}</span>
			</li>
			{else /}
			<li>
				<span class="item_name" style="width:120px;">权限路径：</span>
				<select class="select" name="name" id="authRoute">
					{volist name="authlist" id="vo"}
					<option value="{$key}" >{$vo}</option>
					{/volist}
				</select>
			</li>
		{/present}
		<!--<li>-->
			<!--<span class="item_name" style="width:120px;">权限路径：</span>-->
			<!--<input type="text" name="name" class="textbox textbox_295" />-->
		<!--</li>-->
		<li>
			<span class="item_name" style="width:120px;">权限名称：</span>
			<input type="text" name="title" class="textbox textbox_295" />
		</li>
		<!--<li>-->
			<!--<span class="item_name" style="width:120px;">附加条件：</span>-->
			<!--<input type="text"  name="condition" class="textbox textbox_295" />-->
		<!--</li>-->
		<li>
		<li>
			<span class="item_name" style="width:120px;">是否开启：</span>
			<input type="checkbox" id="checkbox_d1" name="status" class="chk_4" checked="checked" /><label for="checkbox_d1"></label>
		</li>
		<li>
			<span class="item_name" style="width:120px;">所属模块：</span>
			<select class="select" name="modulename" id="platform">
				<option value="">选择所属模块</option>
				{volist name="modules" id="vo"}
					<option value="{$vo['id']}" >{$vo['modulename']}</option>
				{/volist}
			</select>
		</li>
		<li>
			<span class="item_name" style="width:120px;"></span>
			<input type="submit" class="link_btn addAuth" style="margin-left: 300px" />
		</li>
	</ul>
</section>
<script>

	$('.addAuth').click(function () {
		//检测账号
		var name = $('#authRoute option:selected').val();
		if(!name)
		{
			msg_warning('请选择权限路径');
			return false;
		}
		var title = $("input[name=title]").val();
		var condition = $("input[name=condition]").val();
		//checkbox属性
		if($("input[type='checkbox']").is(':checked'))
		{
			var status = 1;
		}else
		{
			var status = 0;
		}
		//选择用户组
		var modulename = $('#platform option:selected').val();
		var data = {name:name,title:title,condition:condition,status:status,modules:modulename};
		send_data = {
			url:U('admin/Auth/addAuthHandle'),
			type:'POST',
			data:data,
			dataType:'json',
		};
		send_ajax(send_data,function(res){
			if(res.status == 1){
				msg_success('添加成功','',2000);
				setTimeout(function(){
					admin.getContentByUrl(res.data.jumpurl);
				},2000);
			}else{
				msg_error(res.message);
			}
		})
	});

	$(function(){
		//调用登陆部分的js
		$(window).keyup(function(e){
			if(e.keyCode == 13){
				$(".addAuth").click();
			}
		})
	});
</script>
